<template>
	<view @click="goDetail()" class="card">
		<view class="title">
			<image v-if="props.order.order_service=='1'" src="../../../static/home/feed.png"></image>
			<image v-if="props.order.order_service=='2'" src="../../../static/home/liu.png"></image>
			<image v-if="props.order.order_service=='3'" src="../../../static/home/jiyang.png"></image>
			<text v-if="props.order.order_service=='1'">上门喂宠</text>
			<text v-if="props.order.order_service=='2'">上门遛宠</text>
			<text v-if="props.order.order_service=='3'">寄养服务</text>
			<uni-icons type="right"></uni-icons>
		</view>
		<view class="detail">
			<image :src="props.order.order_image"></image>
			<view class="xinxi">
				<view class="name">
					<view v-for="(item,index) in props.order.order_pet" :key="item.pet_id">
						{{item.pet_name}};
					</view>
				</view>
				<view class="gender">
					<view v-for="(item,index) in props.order.order_pet" :key="item.pet_id">
						<text v-if="item.pet_gender===0">女;</text>
						<text v-if="item.pet_gender===1">男;</text>
					</view>
				</view>
				<view class="varity">
					<view v-for="(item,index) in props.order.order_pet" :key="item.pet_id">
						{{item.pet_variety}};
					</view>
				</view>
			</view>
		</view>
		<view class="button">
			<view @click.stop="changestatus(6)" v-if="props.order.order_status==='1'||props.order.order_status==='2'||props.order.order_status==='3'" class="button-item">退款</view>
			<view @click.stop="changestatus(4)" v-if="props.order.order_status==='3'" class="button-item">确认完成</view>
			<view @click.stop="gopingjia()" v-if="props.order.order_status==='4'" class="button-item">立即评价</view>
		</view>
		<slot name="bottom"></slot>
	</view>
</template>

<script lang="ts" setup>
	import {ref,reactive,defineProps,defineEmits} from "vue"
	import http from "@/utils/request.js"
	interface Props {
	   order:Object
	}  
	const props=defineProps<Props>()
	const emits=defineEmits(['changefresh'])
	function goDetail(){
		emits('changefresh',1)
		uni.navigateTo({
			url:"/pages/order/detail?order="+JSON.stringify(props.order)
		})
	}
	function changestatus(e){
		let response=http.post('/order/changestatus',{
			order_id:props.order.order_id,
			order_status:e
		})
		response.then(res=>{
			if(res.data.code===200){
				uni.showToast({
					title:'操作成功',
					duration:1000
				})
			}
		})
	}
	function gopingjia(){
		uni.navigateTo({
			url:"/pages/order/pingjia?service_id="+props.order.order_service+"&people_id="+props.order.order_people.people_id+"&order_id="+props.order.order_id
		})
	}
</script>

<style lang="scss">
	.card{
		width: 100%;
		background-color: #fff;
		box-sizing: border-box;
		padding: 20rpx;
		border-radius: 20rpx;
		margin-bottom: 10rpx;
		
		.title{
			width: 100%;
			display: flex;
			align-items: center;
			margin-bottom: 20rpx;
			font-size: 30rpx;
			
			image{
				width: 40rpx;
				height: 40rpx;
				margin-right: 5rpx;
			}
		}
		
		.detail{
			display: flex;
			width: 100%;
			box-sizing: border-box;
			padding: 0 10rpx;
					
			image{
				width: 20%;
				height: 150rpx;
				margin-right: 20rpx;
			}
			
			.xinxi{
				width: 80%;
				
				.name,.gender,.varity{
					width: 100%;
					display: flex;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
				}
			}
		}
	}
	.button{
		display: flex;
		width: 100%;
		box-sizing: border-box;
		justify-content: flex-end;
		margin-bottom: 40rpx;
		padding: 0 20rpx;
		
		&-item{
			background-color: #f3f6f7;
			border-radius: 20rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			width: 150rpx;
			height: 60rpx;
			margin-left: 20rpx;
		}
	}
</style>
